<template>
  <LdbpPage
    pageName="qyml"
    zh_name="全域美丽"
    :rankList_title="rankList_title"
    :rankList_th="rankList_th"
    :rankList_4="rankList_4"
    :rankList_6="rankList_6"
    :rankList_8="rankList_8"
    :info="info"
  ></LdbpPage>
</template>

<script>
import axios from 'axios'
import LdbpPage from '../../components/LdbpPage'

export default {
  name: 'Qyml',
  components: { LdbpPage },
  data() {
    return {
      info: '全域美丽以环境大整治以及美丽城镇建设两大比拼通过挂图作战，月度亮榜，督查考核的方式切实巩固城市环境百日集中攻行动，持续健全全城市长效管理机制，重点推进乡镇样板创建工作，全面提升城市环境美化水平。',
      rankList_title: ['环境大整治（牵头单位）', '环境大整治（乡镇街道）', '美丽城镇（乡镇）', '美丽城镇（部门组）'],
      rankList_th: [
        ['', '', '总分'],
        ['', '', '总分'],
        ['', '', '总分'],
        ['', '', '总分']
      ],
      rankList_4: [],
      rankList_6: [],
      rankList_8: [],
    };
  },
  mounted() {
    // 四月
    this.request('/EnvironRenovation/getLeadUnitList', '4', 0) // 环境大整治（牵头单位）
    this.request('/EnvironRenovation/getTownshipList', '4', 1) // 环境大整治（乡镇街道）
    this.request('/BeautifulTown/getTownshipList', '4', 2) // 美丽城镇（乡镇）
    this.request('/BeautifulTown/getDepartmentList', '4', 3) // 美丽城镇（部门组）
    // 六月
    this.request('/EnvironRenovation/getLeadUnitList', '6', 0)
    this.request('/EnvironRenovation/getTownshipList', '6', 1)
    this.request('/BeautifulTown/getTownshipList', '6', 2)
    this.request('/BeautifulTown/getDepartmentList', '6', 3)
    // 八月
    this.request('/EnvironRenovation/getLeadUnitList', '8', 0)
    this.request('/EnvironRenovation/getTownshipList', '8', 1)
    this.request('/BeautifulTown/getTownshipList', '8', 2)
    this.request('/BeautifulTown/getDepartmentList', '8', 3)
  },
  methods: {
    request(url, month, index) {
      // 月份参数处理
      let newMonth;
      if (month === '6') {
        newMonth = '5-6'
      }
      if (month === '8') {
        newMonth = '7'
      }
      axios({
        method: 'post',
        url: 'https://lst.jiande.gov.cn:8443/competition_jiande' + url,
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        params: { month: newMonth || month }
      })
        .then(({data: {data}}) => {
          console.log('res', month, data);
          if (data) {
            this['rankList_' + month][index] = data
          }
        })
        .catch(err => {
          console.log('err', err);
        });
    }
  }
};
</script>